/**
 * 
 * If you have edited the file, please update
 * all the last-modified fields manually. Thanks!
 *
 * @last-modified by: 
 * @last-modified date: 
 * @last-modified time: 
 *
 * @author Swee Zhi
 * @date-created Oct 24, 2011    @time-created 6:28:54 PM
 *
 * @project: 
 * @module: 
 * @institution: 
 *
 */
package util.comboloader;

import java.util.ArrayList;
import java.util.List;
import javax.enterprise.context.RequestScoped;
import javax.faces.bean.ManagedBean;
import javax.faces.model.SelectItem;
import util.enumeration.UserRoleType;
import util.enumhelper.LocalizedUserRoleType;
import util.localization.WebLocalization;

@ManagedBean(name="enumUserRoleType")
@RequestScoped
public class EnumUserRoleType {
    private WebLocalization localization;
    //  user preferred locale
    private String preferredLocale;
    //The list with the items
    public List<SelectItem> listItems = null;


    /** Creates a new instance of EnumUserRoleType */
    public EnumUserRoleType() {
        /* LOCALIZATION */
        localization = new WebLocalization();
        preferredLocale = localization.getPreferredLocaleFromSession();
        /* END LOCALIZATION */
        
        // load combobox
        loadCombo();
    }
    
    //Loading the items
    private void loadCombo() {
        listItems = new ArrayList<SelectItem>();
        listItems.add(new SelectItem(null, LocalizedSelect.getLocalizedSelectAsString(preferredLocale)));

        for (UserRoleType u : UserRoleType.values()) {
            //  object value, string value (what u wan users to see)
            String localizedInterest = LocalizedUserRoleType.getLocalizedUserRoleTypeAsString(u, preferredLocale);
            listItems.add(new SelectItem (u, localizedInterest));
        }
    }

    public List<SelectItem> getListItems() {
        return listItems;
    }

    public void setListItems(List<SelectItem> listItems) {
        this.listItems = listItems;
    }
}
